<?php

namespace Biz\module\Classes\wiki;

use hhz\constant\redis\redisKeys;
use Biz\cache\album\AlbumWikiCache;
use Biz\cache\brand\BrandWikiBuyAndFavCache;
use Biz\cache\wiki\ShortTitle;
use Biz\cache\wiki\WikiBasicCounter;
use Biz\model\Album\AlbumWikiListModel;
use Biz\model\brandActivity\BrandActivityBasic;
use Biz\model\GoodsTestActivity\FineGoodsContentModel;
use Biz\model\ShopFavorite as mShopFavorite;
use Biz\model\wiki\Wiki as mWiki;
use Biz\model\wiki\WikiBasic as mWikiBasic;
use Biz\module\Classes\wiki\Wiki as clsWiki;
use Biz\module\Classes\wiki\WikiBasic as clsWikiBasic;
use Biz\pockets\constInterface\WikiFields;
use Biz\pockets\serviceTrait\_Async;
use Biz\service\brand\Brand;
use Biz\service\brand\BrandActivity;
use Biz\service\NewProduct\NewProductWinnerListService;
use Biz\service\Share;
use Biz\service\Store\StoreBasicService;
use Biz\service\wiki\WikiBuyService;
use Biz\service\wikiRanking\Ranking;
use Biz\tools\BizUrl;
use Biz\tools\helper\Common;
use Doraemon\pockets\publicTrait\CheckConstants;
use Doraemon\service\statSign\Basic as basicStatSign;
use Doraemon\service\User;
use Doraemon\service\UserPortrait\UserPortraitApi;
use Doraemon\tools\BlockType;
use Doraemon\tools\HhzClient;
use Doraemon\tools\Hhzurl;
use Doraemon\tools\ImgUrl;
use Doraemon\tools\Log;
use Doraemon\service\DingTalkAlert;
use Doraemon\tools\Curl;
use Doraemon\pockets\config\IniConfig;
use Doraemon\tools\HhzEnv;
use Hhz\Redis\newCache;

class Infos implements WikiFields
{
    use _Async;
    use CheckConstants;

    const WIKI_DEFAULT_IMG_3X = "https://img.haohaozhu.cn/Op-imageShow/981c4304i04i0CQ00prfs1h?iv=1";
    const GOODS_STATUS_APP_NORMAL = 1;
    const DETAIL = 1; //详情
    const LIST = 2; //列表

    const ACTIVITY_TYPE_BLIND_BOX_IMG_LIST = 'https://img.haohaozhu.cn/Op-imageShow/88ab5304901c0Tr00qil3g3?iv=1';//盲盒 列表页icon
    const ACTIVITY_TYPE_BLIND_BOX_IMG_DETAIL = 'https://img.haohaozhu.cn/Op-imageShow/4a1d0303602i0a600qilbc9?iv=1';//盲盒 详情页icon

    const ACTIVITY_TYPE_NEW_PRODUCT_IMG_DETAIL = 'https://img.haohaozhu.cn/Biz-imageShow/o_phone/6f4/5e4cf303602i0LP00qv31r8?iv=1';//新品速递 详情页icon
    const ACTIVITY_TYPE_NEW_PRODUCT_IMG_LIST = '';//新品速递 列表页icon

    const ACTIVITY_TYPE_LIGHT_TEST_IMG_LIST = 'https://img.haohaozhu.cn/App-imageShow/sq_thumb/743c3303r01c0IU00rqkuo173v15';//好物亲测 列表页icon
    const ACTIVITY_TYPE_LIGHT_TEST_IMG_DETAIL = 'https://img.haohaozhu.cn/Op-imageShow/f91ec303o03o08A00rd9dbp?iv=1';//好物亲测 详情页icon


    /**
     * @param $wikiIds
     * @param string $fieldsGroup 筛选条件
     * @param int $uid 当前用户uid
     * @return array
     * @throws /Exception
     */
    public static function infos($wikiIds, $fieldsGroup = self::FIELDS_GROUP_LIST, $uid = 0): array
    {
        if (in_array($fieldsGroup, self::SCENEMAP)) {
            return self::getWikiFromGrpc($fieldsGroup, $wikiIds, $uid);
        }
        self::_verfyParams($wikiIds, $fieldsGroup);
        $infos = clsWiki::getWikiBaseInfos($wikiIds);
        $basicIds = array_column($infos, 'basic_id');
        $brandIds = array_column($infos, 'brand_id');
        $brandIds = array_unique(array_filter($brandIds));
        $basicInfos = $basicIds ? clsWikiBasic::getWikiBasicInfos($basicIds) : [];

        switch ($fieldsGroup) {
            case self::FIELDS_GROUP_BASE_DETAIL:
                $infos = self::_getDefaultInfos($infos, $basicInfos);
                //$infos = self::_getStoreInfos($infos, $storeIds);//门店业务下线
                $infos = self::_getBrandInfosForDetail($infos, $brandIds, $uid);
                $infos = self::_isFavWikis($infos, $uid);
                $infos = self::_isBuyWikis($infos, $uid);
                $infos = self::_getBasicCounters($infos, $basicIds);
                break;
            case self::FIELDS_GROUP_DETAIL:
                $infos = self::_getDefaultInfos($infos, $basicInfos);
                $infos = self::_getWikiContents($infos, $wikiIds, $basicInfos);
                //$infos = self::_getStoreInfos($infos, $storeIds);//门店业务下线
                $infos = self::_getBrandInfosForDetail($infos, $brandIds, $uid);
                $infos = self::_isFavWikis($infos, $uid);
                $infos = self::_isBuyWikis($infos, $uid);
                $infos = self::_getBasicCounters($infos, $basicIds);
                $infos = self::getOpenAppLink($infos);
                $infos = self::_getRankingListInfos($infos, $basicIds);
                $infos = self::_getActivityInfos($infos, $basicIds, self::DETAIL);
                $infos = self::_getRecommendUserInfos($infos);
                $infos = self::_getAlbumInfos($infos, $wikiIds, $fieldsGroup);
                $infos = self::_getRecommendList($infos, $wikiIds, $fieldsGroup);
                break;
            case self::FIELDS_GROUP_FUNENG_DETAIL:
                $infos = self::_getWikiContents($infos, $wikiIds, $basicInfos);
                $infos = self::_getBrandInfosForDetail($infos, $brandIds, $uid);
                $infos = self::_isFavWikis($infos, $uid);
                $infos = self::_isBuyWikis($infos, $uid);
                $infos = self::_getBasicCounters($infos, $basicIds);
                $infos = self::getOpenAppLink($infos, $fieldsGroup);
                break;
            case self::FIELDS_GROUP_MIDDLE_LIST:
                $infos = self::_getWikiImgs($infos, $wikiIds, $basicInfos);
                //$infos = self::_getStoreInfos($infos, $storeIds);//门店业务下线
                $infos = self::_getBrandInfos($infos, $brandIds);
                $infos = self::_isFavWikis($infos, $uid);
                $infos = self::_isBuyWikis($infos, $uid);
                $infos = self::_getBasicCounters($infos, $basicIds);
                $infos = self::getOpenAppLink($infos);
                $infos = self::_getRankingListInfos($infos, $basicIds);
                $infos = self::_getActivityInfos($infos, $basicIds, self::LIST);
                $infos = self::_getShortTitleInfos($infos, $wikiIds);
                $infos = self::_getRecommendUserInfos($infos);
                $infos = self::_getAlbumInfos($infos, $wikiIds, $fieldsGroup);
                $infos = self::_getRecommendList($infos, $wikiIds, $fieldsGroup);
                break;
            case self::FIELDS_GROUP_NEW_PRODUCT_MY_LIKE:
                $infos = self::_getWikiImgs($infos, $wikiIds, $basicInfos);
                //$infos = self::_getStoreInfos($infos, $storeIds);//门店业务下线
                $infos = self::_getBrandInfos($infos, $brandIds);
                $infos = self::_isFavWikis($infos, $uid);
                $infos = self::_isBuyWikis($infos, $uid);
                $infos = self::_getBasicCounters($infos, $basicIds);
                $infos = self::_getRankingListInfos($infos, $basicIds);
                $infos = self::_getRecommendUserInfos($infos);
                $infos = self::_getRecommendList($infos, $wikiIds, $fieldsGroup);
                break;
            case self::FIELDS_GROUP_TNG_BEFORE_LIST:
                $infos = self::_getBasicCounters($infos, $basicIds);
                $infos = self::_getRecommendUserInfos($infos);
                $infos = self::_getBrandInfos($infos, $brandIds, true);
                $infos = self::getOpenAppLink($infos);
                break;

        }

        switch ($fieldsGroup) {
            case self::FIELDS_GROUP_BASE_DETAIL:
            case self::FIELDS_GROUP_DETAIL:
            case self::FIELDS_GROUP_FUNENG_DETAIL:
                $infos = self::_formatDetail($infos, $basicInfos, $fieldsGroup, $uid);
                break;
            case self::FIELDS_GROUP_NEW_PRODUCT_MY_LIKE:
            case self::FIELDS_GROUP_MIDDLE_LIST:
                $infos = self::_formatMiddleList($infos, $basicInfos, $uid);
                break;
            case self::FIELDS_GROUP_TNG_BEFORE_LIST:
                $infos = self::_formatTodayBeforeList($infos, $basicInfos, $uid); //获取今日好物往期列表
                break;
        }
        $result = [];
        if (empty($infos)) {
            return $result;
        }
        foreach ($wikiIds as $wikiId) {
            if (isset($infos[$wikiId])) {
                $result[$wikiId] = $infos[$wikiId];
            }
        }
        return $result;
    }

    /**
     * 是否喜欢
     * @param array $infos
     * @param int $uid
     * @return array
     * @throws \Exception
     */
    private static function _isFavWikis($infos, $uid)
    {
        $appSource = 0;
        if (HhzClient::getClientType() == HhzClient::APPTYPE_PARAGRAPH_MINIPROGRAM) {
            $appSource = HhzClient::APPTYPE_PARAGRAPH_MINIPROGRAM;
        } else {
            if (HhzClient::getClientType() == HhzClient::APPTYPE_DESIGNER_FUNENG_MINIPROGRAM) {
                $appSource = HhzClient::APPTYPE_DESIGNER_FUNENG_MINIPROGRAM;
            }
        }
        if ($uid) {
            $wikiIds = array_keys($infos);
            $isFavList = $wikiIds ? mShopFavorite::is_favorited($uid, $wikiIds, mShopFavorite::TYPE_WIKI, $appSource) : [];
            foreach ($infos as $wikiId => $info) {
                $infos[$wikiId]['is_fav'] = $isFavList[$wikiId];
            }
        } else {
            foreach ($infos as $wikiId => $info) {
                $infos[$wikiId]['is_fav'] = 0;
            }
        }
        return $infos;
    }

    /**
     * 是否买过
     * @param array $infos
     * @return array
     */
    private static function _isBuyWikis($infos, $uid)
    {
        if ($uid) {
            $wikiIds = array_keys($infos);
            $wikiIsBuyMap = $wikiIds ? WikiBuyService::isBuy($uid, $wikiIds) : [];
            foreach ($infos as $wikiId => $info) {
                $infos[$wikiId]['is_buy'] = (int)$wikiIsBuyMap[$wikiId] ?? 0;
            }
        } else {
            foreach ($infos as $wikiId => $info) {
                $infos[$wikiId]['is_buy'] = 0;
            }
        }
        return $infos;
    }

    /**
     * 获取basic计数
     * @param array $infos
     * @param array $basicIds
     * @return array
     */
    private static function _getBasicCounters(array $infos, array $basicIds): array
    {
        if ($basicIds) {
            $counters = WikiBasicCounter::getMulti($basicIds);
            foreach ($infos as $wikiId => $info) {
                $counter = (isset($counters[$info['basic_id']]) && $counters[$info['basic_id']]) ? $counters[$info['basic_id']] : [];
                if ($counter) {
                    $infos[$wikiId]['fav_count'] = $counter[WikiBasicCounter::BASIC_FAVORITE];
                    $infos[$wikiId]['buy_count'] = $counter[WikiBasicCounter::BASIC_BUY]; //商品买过数
                    $infos[$wikiId]['click_buy_num'] = $counter[WikiBasicCounter::BASIC_CLICK_BUY_NUM];
                    $infos[$wikiId]['defined_increment'] = $counter[WikiBasicCounter::BASIC_DEFINED_NUM];
                    $infos[$wikiId]['relate_num'] = $counter[WikiBasicCounter::BASIC_RELATE_NUM];
                    $infos[$wikiId][WikiBasicCounter::BASIC_USER_COMMENT_NUM] = $counter[WikiBasicCounter::BASIC_USER_COMMENT_NUM];
                    $infos[$wikiId][WikiBasicCounter::BASIC_BRAND_COMMENT_NUM] = $counter[WikiBasicCounter::BASIC_BRAND_COMMENT_NUM];
                    $infos[$wikiId][WikiBasicCounter::BASIC_STORE_COMMENT_NUM] = $counter[WikiBasicCounter::BASIC_STORE_COMMENT_NUM];
                    $infos[$wikiId]['talk_about_total'] = $counter[WikiBasicCounter::BASIC_BRAND_COMMENT_NUM] + $counter[WikiBasicCounter::BASIC_USER_COMMENT_NUM];//之前业务需要 不需要加门店说
                } else {
                    $infos[$wikiId]['fav_count'] = 0;
                    $infos[$wikiId]['buy_count'] = 0;
                    $infos[$wikiId]['click_buy_num'] = 0;
                    $infos[$wikiId]['defined_increment'] = 0;
                    $infos[$wikiId]['relate_num'] = 0;
                    $infos[$wikiId][WikiBasicCounter::BASIC_USER_COMMENT_NUM] = 0;
                    $infos[$wikiId][WikiBasicCounter::BASIC_BRAND_COMMENT_NUM] = 0;
                    $infos[$wikiId][WikiBasicCounter::BASIC_STORE_COMMENT_NUM] = 0;
                    $infos[$wikiId]['talk_about_total'] = 0;
                }
            }
        }
        return $infos;
    }

    /**
     * 品牌信息
     * @param $infos
     * @param $brandIds
     * @param bool $hasUid
     * @return array
     */
    private static function _getBrandInfos($infos, $brandIds, $hasUid = false): array
    {
        if ($brandIds) {
            $brandList = Brand::getBrandInfoByIds4Goods($brandIds);
            foreach ($infos as $wikiId => $info) {
                if ($info['brand_id'] && isset($brandList[$info['brand_id']]) && $brandList[$info['brand_id']]) {
                    $brandInfo = $brandList[$info['brand_id']];
                    if (!$hasUid) {
                        $infos[$wikiId]['brand_info'] = $brandInfo;
                    } else if ($brandInfo['uid'] > 0) {
                        $infos[$wikiId]['brand_info'] = $brandInfo;
                    }
                }
            }
        }
        return $infos;
    }

    /**
     * 获取品牌信息(详情页)
     * @param $infos
     * @param $brandIds
     * @param $uid
     * @return array
     */
    private static function _getBrandInfosForDetail($infos, $brandIds, $uid): array
    {
        if ($brandIds) {
            $brandList = Brand::getBrandsInfoByIds($brandIds);
            foreach ($infos as $wikiId => $info) {
                $brandInfo = ($info['brand_id'] && isset($brandList[$info['brand_id']])) ? $brandList[$info['brand_id']] : [];
                if (!empty($brandInfo)) {
                    $userInfo = $brandInfo['uid'] ? User::getUserInfo($brandInfo['uid'], true, $uid) : [];
                    if ($userInfo) {
                        $infos[$wikiId]['brand_info'] = $brandInfo;
                        $infos[$wikiId]['brand_info']['user_info'] = $userInfo;
                    }
                }
            }
        }
        return $infos;
    }

    /**
     * 格式化打开第三方app
     * @param $infos
     * @param null $fieldsGroup
     * @return array
     */
    public static function getOpenAppLink($infos, $fieldsGroup = null)
    {
        $infos = clsWiki::get3rdInfos($infos);
        if ($fieldsGroup != self::FIELDS_GROUP_FUNENG_DETAIL) {//赋能小程序，依然使用3rd_link
            foreach ($infos as &$info) {
                if ($info['channel'] == mWiki::CHANNEL_NOTHING) {
                    $wiki_data['id'] = $info['id'];
                    $info['open_other_link']['link'] = "niceliving://wiki/detail?protego=" . urlencode(base64_encode(json_encode($wiki_data)));
                    $info['open_other_link']['open_app_link'] = "niceliving://wiki/detail?protego=" . urlencode(base64_encode(json_encode($wiki_data)));
                    $info['open_other_link']['title'] = '查看详情';
                    $info['open_other_link']['channel'] = $info['channel'];
                    continue;
                }
                $title = "位置";
                $originalLink = '';//原始链接(h5链接)
                $open_app_link = "";//打开app的链接
                $open_wechat_mini_link = '';//打开微信小程序链接
                $package = '';//包名
                switch ($info['channel']) {
                    case mWiki::CHANNEL_XIAOMIYOUPIN:
                        $title = '去小米有品打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = 'com.xiaomi.youpin';

                        $wechatMiniLink = $info['3rd_link']['channel_mini_url'] ?? '';
                        $fallback = $originalLink ? 'niceliving://webview/normalscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $originalLink]))) : '';
                        $jsonData = [
                            'id' => $info['3rd_link']['weixin_app_id'],
                            'path' => $wechatMiniLink,
                            'fallback' => $fallback
                        ];
                        $open_wechat_mini_link = 'niceliving://open/wechat_miniprogram?protego=' . urlencode(base64_encode(json_encode($jsonData)));
                        break;
                    case mWiki::CHANNEL_AMAZON:
                        $title = '去亚马逊打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = 'cn.amazon.mShop.android';
                        break;
                    case mWiki::CHANNEL_XIAOEPINPIN:
                        $title = '去小鹅拼拼打开';
                        //$open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $open_app_link = '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        //$package = 'com.tencent.dwdcoco';
                        $package = '';
                        break;
                    case mWiki::CHANNEL_SAMSUNGESHOP:
                        $title = '去三星网上商城打开';
                        $open_app_link = $info['3rd_link']['channel_url'] ? 'niceliving://webview/normalscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $info['3rd_link']['channel_url']]))) : '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = '';
                        break;
                    case mWiki::CHANNEL_TAOBAO:
                        $title = '去淘宝打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = BizUrl::APP_PACKAGE_TAOBAO;
                        break;
                    case mWiki::CHANNEL_JD:
                        $title = '去京东打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = BizUrl::APP_PACKAGE_JD;
                        break;
                    case mWiki::CHANNEL_SUNING:
                        $title = '去苏宁打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = '';
                        break;
                    case mWiki::CHANNEL_KAOLA:
                        $title = '去考拉打开';
                        $open_app_link = $info['3rd_link']['channel_app_url'] ?? '';
                        $originalLink = $info['3rd_link']['channel_url'] ?? '';
                        $package = '';
                        break;
                    case mWiki::CHANNEL_YOUZAN:
                        $originalLink = $info['3rd_link']['channel_url'];
                        $wechatMiniLink = $info['3rd_link']['channel_mini_url'] ?? '';
                        $fallback = $originalLink ? 'niceliving://webview/normalscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $originalLink]))) : '';
                        $jsonData = [
                            'id' => $info['3rd_link']['weixin_app_id'],
                            'path' => $wechatMiniLink,
                            'fallback' => $fallback
                        ];
                        $open_wechat_mini_link = 'niceliving://open/wechat_miniprogram?protego=' . urlencode(base64_encode(json_encode($jsonData)));
                        $open_app_link = $open_wechat_mini_link;
                        $title = '去微信打开';
                        $package = BizUrl::APP_PACKAGE_WECHAT_MINIPROGRAM;
                        break;
                }

                if (!in_array($info['channel'], [mWiki::CHANNEL_YOUZAN, mWiki::CHANNEL_SAMSUNGESHOP])) {
                    $fallback = $originalLink ? 'niceliving://webview/normalscreen?protego=' . urlencode(base64_encode(json_encode(['url' => $originalLink]))) : '';
                    $open_app_link = 'niceliving://open/app?protego=' . urlencode(base64_encode(json_encode(['link' => $open_app_link, 'package' => $package, 'fallback' => $fallback])));
                }
                $info['open_other_link']['title'] = $title;
                $info['open_other_link']['open_app_link'] = $open_app_link;
                $info['open_other_link']['open_wechat_mini_link'] = $open_wechat_mini_link;
                $info['open_other_link']['original_link'] = $originalLink;
                $info['open_other_link']['channel'] = $info['channel'];
            }
        }
        return $infos;

    }

    /**
     * 获取榜单信息
     * @param $infos
     * @param $basicIds
     * @return array
     */
    private static function _getRankingListInfos($infos, $basicIds): array
    {
        $rankingList = $basicIds ? Ranking::getWikiRanking($basicIds) : [];
        foreach ($infos as $wikiId => $info) {
            $rankingArr = $rankingList[$info['basic_id']] ?? [];
            $rankingInfo = ($rankingArr && $rankingArr[0]) ? $rankingArr[0] : [];
            if ($rankingInfo) {
                $rankingInfo['link'] = Ranking::getRankingUrl($rankingInfo['ranking_id'], $rankingInfo['type']);
                $infos[$wikiId]['ranking_info'] = $rankingInfo;
            }
        }
        return $infos;
    }

    /**
     * 获取活动信息
     * @param $infos
     * @param $basicIds
     * @param $flag
     * @return array
     */
    private static function _getActivityInfos($infos, $basicIds, $flag): array
    {
        $activityList = $basicIds ? BrandActivityBasic::getActivityByBasicIds($basicIds) : [];
        $activityList = NewProductWinnerListService::handleData($activityList, 'basic_id');
        $hasReports = [];
        if ($flag == self::DETAIL) {
            $hasReports = $basicIds ? FineGoodsContentModel::hasReport($basicIds) : [];
        }
        foreach ($infos as $wikiId => $info) {
            if ($flag == self::DETAIL) {
                $infos[$wikiId]['has_report'] = $hasReports[$info['basic_id']] ?? 0;
            }
            $activityInfo = $activityList[$info['basic_id']] ?? [];
            if ($activityInfo) {

                [$iconList, $iconDetail, $link] = self::_getIconAndLinkByType($activityInfo['activity_type'], $activityInfo['activity_id']);

                if ($flag == self::DETAIL) {
                    $icon = $iconDetail;
                } else {
                    $icon = $iconList;
                }
                $infos[$wikiId]['activity_list'] = [
                    [
                        'id' => $activityInfo['activity_id'],
                        'type' => $activityInfo['activity_type'],
                        'title' => '',
                        'icon' => $icon,
                        'link' => $link,
                    ]
                ];
            }
        }
        return $infos;
    }

    /**
     * 获取活动图标
     * @param $type
     * @param $activityId
     * @return string[]
     */
    private static function _getIconAndLinkByType($type, $activityId): array
    {
        switch ($type) {
            case BrandActivityBasic::ACTIVITY_TYPE_BLIND_BOX:
                $iconList = self::ACTIVITY_TYPE_BLIND_BOX_IMG_LIST;
                $iconDetail = self::ACTIVITY_TYPE_BLIND_BOX_IMG_DETAIL;
                $link = BrandActivity::getBlindBoxLink();
                break;
            case BrandActivityBasic::ACTIVITY_TYPE_NEW_PRODUCT:
                $iconList = self::ACTIVITY_TYPE_NEW_PRODUCT_IMG_LIST;
                $iconDetail = self::ACTIVITY_TYPE_NEW_PRODUCT_IMG_DETAIL;
                $link = BrandActivity::getNewProductLink();
                break;
            case BrandActivityBasic::ACTIVITY_TYPE_LIGHT_TEST:
                $iconList = self::ACTIVITY_TYPE_LIGHT_TEST_IMG_LIST;
                $iconDetail = self::ACTIVITY_TYPE_LIGHT_TEST_IMG_DETAIL;
                $link = BrandActivity::getFindGoodsTestLink($activityId);
                break;
            default:
                $iconList = '';
                $iconDetail = '';
                $link = '';
        }
        return [$iconList, $iconDetail, $link];
    }

    /**
     * 匹配wiki图片
     * @param $infos
     * @param $wikiIds
     * @param $basicInfos
     * @return array
     */
    private static function _getWikiImgs($infos, $wikiIds, $basicInfos): array
    {
        $contentInfos = clsWiki::getWikiContentInfos($wikiIds);
        foreach ($infos as $wikiId => $info) {
            $contentInfo = $contentInfos[$wikiId] ?? [];
            $imgs = (isset($contentInfo['imgs']) && $contentInfo['imgs']) ? json_decode($contentInfo['imgs'], true) : [];

            $basicInfo = (isset($basicInfos[$info['basic_id']]) && $basicInfos[$info['basic_id']]) ? $basicInfos[$info['basic_id']] : [];
            if ($basicInfo && isset($basicInfo['img_urls']) && $basicInfo['img_urls']) {
                $basicImgUrls = $basicInfo['img_urls'] ?? [];
                $imgs = array_merge($basicImgUrls, $imgs);
            }

            $infos[$wikiId]['imgs'] = $imgs ?: [];
        }
        return $infos;
    }

    /**
     * 获取wikiContent
     * @param $infos
     * @param $wikiIds
     * @param $basicInfos
     * @return array
     */
    private static function _getWikiContents($infos, $wikiIds, $basicInfos)
    {
        $contentInfos = clsWiki::getWikiContentInfos($wikiIds);
        foreach ($infos as $wikiId => $info) {
            $contentInfo = $contentInfos[$wikiId] ?? [];
            $imgs = ($contentInfo && $contentInfo['imgs']) ? json_decode($contentInfo['imgs'], true) : [];
            $detail_imgs = ($contentInfo && $contentInfo['detail_imgs']) ? json_decode($contentInfo['detail_imgs'], true) : [];
            if ($info['channel'] != mWiki::CHANNEL_NOTHING) {
                $basicInfo = $basicInfos[$info['basic_id']] ?? [];
                if ($basicInfo && isset($basicInfo['img_urls']) && $basicInfo['img_urls']) {
                    $basicImgUrls = $basicInfo['img_urls'] ?? [];
                    $imgs = array_merge($basicImgUrls, $imgs);
                }

                $infos[$wikiId]['imgs'] = !empty($imgs) ? $imgs : [];
                $infos[$wikiId]['goods_detail'] = $contentInfo ? $contentInfo['content'] : '';
            } else {
                $infos[$wikiId]['goods_img_detail'] = [];
                foreach ($detail_imgs as $v) {
                    $infos[$wikiId]['goods_img_detail'][] = ImgUrl::getUrl(ImgUrl::APPTYPE_BIZ, $v,
                        ImgUrl::IMAGE_SIZE_ORI_PHONE_BIG);
                }
            }
        }
        return $infos;
    }

    /**
     * 获取基础信息
     * @param $infos
     * @param $basicInfos
     * @return array
     */
    private static function _getDefaultInfos($infos, $basicInfos): array
    {
        $result = [];
        foreach ($infos as $wikiId => $info) {
            if ($info['basic_id'] && isset($basicInfos[$info['basic_id']]) && $basicInfos[$info['basic_id']]) {
                if ($basicInfos[$info['basic_id']]['brand_id'] > 0 && $basicInfos[$info['basic_id']]['basic_state'] == mWikiBasic::STATE_ONLINE) {
                    $defaultInfo = mWiki::getByWhere([
                        'basic_id' => $info['basic_id'],
                        'is_default' => mWiki::IS_DEFAULT,
                        'status[!]' => mWiki::STATUS_DEL
                    ]);
                    $info = $defaultInfo ?: $info;
                }
            }
            $result[$wikiId] = $info;
        }
        return $result;
    }

    /**
     * 获取住友想要信息
     * @param $infos
     * @return array
     */
    private static function _getRecommendUserInfos($infos): array
    {
        $wikiCount = count($infos);
        $buyNum = $wikiCount * 3;
        $recommendationUserImgs = clsWiki::getRandUserCoverImg($buyNum);
        foreach ($infos as $wikiId => $info) {
            $buyNum = $info['click_buy_num'] + $info['fav_count'] + $info['defined_increment'];
            $recommendation = $buyNum ? $buyNum . '位住友想买' : '';
            if ($info['store_id'] > 0) {
                $recommendation = $buyNum ? $buyNum . '位住友喜欢' : '';
            }
            $imgCount = $buyNum >= 3 ? 3 : $buyNum;//5.9.0 调整
            $recommendationUser = [];
            if ($imgCount && $recommendationUserImgs) {
                $randIndexArr = array_rand($recommendationUserImgs, $imgCount);
                if (!is_array($randIndexArr)) {//array_rand num=1 返回非数组
                    $randIndexArr = (array)$randIndexArr;
                }
                foreach ($randIndexArr as $key) {
                    $recommendationUser[] = $recommendationUserImgs[$key];
                }
            }
            $infos[$wikiId]['recommendation'] = $recommendation;
            $infos[$wikiId]['recommendation_user'] = $recommendationUser;
            $infos[$wikiId]['want_person_avatars'] = $recommendationUser ? array_column($recommendationUser, 'cover_img') : [];
        }
        return $infos;
    }

    /**
     * 获取好物清单信息
     * @param $infos
     * @param $wikiIds
     * @param $fieldsGroup
     * @return mixed
     */
    public static function _getAlbumInfos($infos, $wikiIds, $fieldsGroup)
    {

        $wikiAlbumIdsMap = AlbumWikiListModel::getLatestAlbumId($wikiIds) ?? [];
        $albumInfos = [];
        if($wikiAlbumIdsMap){
            $newRedis = new newCache(redisKeys::KEY_B_CACHE_ALBUM_W_DETAIL);
            $albumInfos = $newRedis->getCaches($wikiAlbumIdsMap)[0]??[];
        }

        foreach ($infos as $wikiId => $row) {
            $albumId = $wikiAlbumIdsMap[$wikiId] ?? '';
            $albumInfo = $albumInfos[$albumId] ?? [];
            if ($albumInfo) {
                //优先 如果缓存中有商品id 则根据id去取商品图片
                if (isset($albumInfo['wiki_ids']) && !empty($albumInfo['wiki_ids'])) {
                    $wikiInfos = clsWiki::getWikiBaseInfos($albumInfo['wiki_ids']);
                    $wikiImgArr = array_column($wikiInfos, 'cover_img');
                } else { //部分历史数据是是图片链接 6.3版本上线之后的数据  不会再存储图片链接 而是只存储商品id
                    $wikiImgArr = $albumInfo['wiki_imgs'];
                }
                $albumInfoData = [
                    'id' => $albumInfo['album_id'],
                    'title' => $albumInfo['album_title'],
                    'wiki_imgs' => $wikiImgArr ?? []
                ];
                if ($fieldsGroup != self::FIELDS_GROUP_DETAIL) {
                    unset($albumInfoData['wiki_imgs']);
                }
                $infos[$wikiId]['album_info'] = $albumInfoData;
            }

        }
        return $infos;
    }

    /**
     * 获取短标题
     * @param $infos
     * @param $wikiIds
     * @return array
     * @throws \Exception
     */
    private static function _getShortTitleInfos($infos, $wikiIds): array
    {
        $shortTitleList = ShortTitle::getMulti($wikiIds);
        foreach ($infos as $wikiId => $info) {
            $shortTitle = $shortTitleList[$wikiId] ?? [];
            $infos[$wikiId]['short_title'] = $shortTitle;
        }
        return $infos;
    }

    /**
     * 获取滚动信息
     * 当_getRankingListInfos或者_getRecommendUserInfos 被调用时 调用此方法
     * @param $infos
     * @param array $wikiIds
     * @param string $fieldsGroup
     * @return array
     */
    private static function _getRecommendList($infos, $wikiIds, string $fieldsGroup): array
    {
        $uid = HhzClient::getUid();
        $wikiBuyAndFavData[] = [];
        $wikiBuyAndFavDataUserList = [];

        foreach ($infos as $wikiId => $info) {
            if (isset($wikiBuyAndFavData[$wikiId]) && $wikiBuyAndFavData[$wikiId] && $wikiBuyAndFavDataUserList) {
                $buyOrFavUid = $wikiBuyAndFavData[$wikiId]['uid'];
                $buyOrFavType = $wikiBuyAndFavData[$wikiId]['type'];
                $wikiBuyAndFavUserInfo = $wikiBuyAndFavDataUserList[$buyOrFavUid] ?? [];
                if ($wikiBuyAndFavUserInfo && $buyOrFavUid && $buyOrFavType) {
                    $infos[$wikiId]['recommend_list'][] = [
                        'type' => $buyOrFavType,
                        'nick' => $wikiBuyAndFavUserInfo['nick'],
                        'avatar' => [$wikiBuyAndFavUserInfo['small_avatar']],
                    ];
                }
            }
            if (isset($info['ranking_info']) && !empty($info['ranking_info'])) {
                $infos[$wikiId]['recommend_list'][] =
                    [
                        "type" => mWikiBasic::WIKI_RECOMMEND_LIST_TYPE_RANKING_INFO,
                        "ranking_info" => $info['ranking_info']['ranking_title'] ?? '',
                    ];
            }
            if (isset($info['recommendation']) && !empty($info['recommendation']) && isset($info['want_person_avatars']) && !empty($info['want_person_avatars']))
                $infos[$wikiId]['recommend_list'][] = [
                    "type" => mWikiBasic::WIKI_RECOMMEND_LIST_TYPE_RECOMMEND,
                    "recommendation" => $info['recommendation'],
                    "avatar" => $info['want_person_avatars'],
                ];
        }
        return $infos;

    }

    /**
     * 详情格式化
     * @param $infos
     * @param $basicInfos
     * @param $fieldsGroup
     * @param $uid
     * @return array
     */
    private static function _formatDetail($infos, $basicInfos, $fieldsGroup, $uid): array
    {
        $formatData = [];
        foreach ($infos as $wikiId => $info) {
            $title = $info['simple_title'] ? $info['simple_title'] : $info['title'];
            $coverImg = $info['cover_img'];
            $imgs = $info['imgs'] ?? [];
            $basicInfo = $basicInfos[$info['basic_id']] ?? [];
            if ($basicInfo) {
                if (($basicInfo['brand_id'] > 0 || $basicInfo['store_id'] > 0) && $basicInfo['basic_state'] == mWikiBasic::STATE_ONLINE && $basicInfo['title']) {
                    $title = $basicInfo['title'];
                }
                if (isset($basicInfo['cover_img_url']) && $basicInfo['cover_img_url']) {
                    $coverImg = $basicInfo['cover_img_url'];
                }
                if (isset($basicInfo['img_urls']) && !empty($basicInfo['img_urls'])) {
                    $imgs = $basicInfo['img_urls'];
                }
            }
            if (empty($title)) {
                continue;
            }

            $data = [
                'id' => $info['id'],
                'title' => $title,
                'ori_min_price' => $info['min_price'],
                'ori_max_price' => $info['max_price'],
                'actual_min_price' => $info['min_price'],
                'actual_max_price' => $info['max_price'],
                'cover_img' => $coverImg,
                'category_id' => $info['category_id'],
                'second_category_id' => $info['second_category_id'],
                "channel_jump_params" => $info['channel_jump_params'],
                'channel' => $info['channel'],
                'imgs' => $imgs,
                'is_fav' => $info['is_fav'],
                'is_buy' => $info['is_buy'],
                'fav_count' => $info['fav_count'],
                'buy_count' => $info['buy_count'],
                'basic_id' => $info['basic_id'],
                'brand_id' => $info['brand_id'],
                'store_id' => $info['store_id'],
                'goods_detail' => $info['goods_detail'] ?: '',
                'goods_img_detail' => $info['goods_img_detail'] ?: '',
                'share_info' => [],
                'brand_name' => '',
                'brand_info' => null,
                'relate_num' => $info['relate_num'],
                'recommendation' => $info['recommendation'] ?? '',
                'recommendation_user' => $info['recommendation_user'] ?? '',
                'want_person_avatars' => $info['want_person_avatars'] ?? '',
                'recommend_list' => $info['recommend_list'] ?? [],
            ];
            if (isset($info['3rd_link']) && $info['3rd_link']) {
                if ($fieldsGroup == self::FIELDS_GROUP_FUNENG_DETAIL) {
                    $data['3rd_link'] = $info['3rd_link'];
                } else {
                    $data['open_other_link'] = $info['open_other_link'] ?? [];
                }
            }
            if (isset($info['ranking_info']) && $info['ranking_info']) {
                $data['ranking_info'] = $info['ranking_info'];
            }
            if (isset($info['activity_list']) && $info['activity_list']) {
                $data['activity_info'] = $info['activity_list'][0];
            }
            if (isset($info['has_report'])) {
                $data['has_report'] = $info['has_report'];
            }
            if (isset($info['album_info']) && $info['album_info']) {
                $data['album_info'] = $info['album_info'];
                $statSign = basicStatSign::genStatSign(basicStatSign::MODULE_WIKI_DETAIL_GOODS_ALBUM, [
                    basicStatSign::EXTEND_KEY_OBJ_ID => $info['album_info']['id'],
                    basicStatSign::EXTEND_KEY_OBJ_TYPE => BlockType::TYPE_WIKI_ALBUM,
                ], ['wiki_id' => $info['id']]);
                $data['album_info']['statSign'] = $statSign;
            }
            if (isset($info['brand_info']) && $info['brand_info']) {
                $brandInfo = $info['brand_info'];
                if ($fieldsGroup == self::FIELDS_GROUP_DETAIL && $brandInfo['uid']) {
                    $userInfo = User::getUserInfo($brandInfo['uid'], true, $uid);
                    $basicList = mWikiBasic::selectByWhere([
                        'basic_state' => mWikiBasic::STATE_ONLINE,
                        'brand_id' => $info['brand_id'],
                        'id[!]' => $info['basic_id']
                    ], ['id', 'title']);
                    $basicIds = $basicList ? array_column($basicList, 'id') : [];
                    $basicList = $basicList ? array_column($basicList, null, 'id') : [];
                    $spuList = $basicIds ? mWiki::selectByWhere([
                        'brand_id' => $info['brand_id'],
                        'is_default' => mWiki::IS_DEFAULT,
                        'basic_id' => $basicIds,
                        'status[!]' => [mWiki::STATUS_DEL, mWiki::STATUS_NORMAL]
                    ], ['id', 'basic_id', 'cover_img', 'title']) : [];
                    $brandInfo['user_info'] = $userInfo;
                    $i = 0;
                    foreach ($spuList as &$row) {
                        $row['title'] = $basicList[$row['basic_id']]['title'] ?? $row['title'];
                        $statSign = basicStatSign::genStatSign(basicStatSign::MODULE_WIKI_DETAIL_BRAND_CARD, [
                            basicStatSign::EXTEND_KEY_OBJ_ID => $row['basic_id'],
                            basicStatSign::EXTEND_KEY_OBJ_TYPE => BlockType::TYPE_WIKI_BASIC,
                            basicStatSign::EXTEND_KEY_INDEX => $i,
                        ]);
                        $row['statSign'] = $statSign;
                        $i++;
                    }
                    $brandInfo['spu_list'] = $spuList;
                }
                $data['brand_info'] = $brandInfo;
                $data['brand_name'] = $brandInfo['name'];
            }
            if (isset($info['store_info']) && $info['store_info']) {
                $storeInfo = $info['store_info'];
                if ($fieldsGroup == self::FIELDS_GROUP_DETAIL && $storeInfo['uid']) {
                    $userInfo = User::getUserInfo($storeInfo['uid'], true, $uid);
                    $basicIds = mWikiBasic::selectByWhere([
                        'basic_state' => mWikiBasic::STATE_ONLINE,
                        'store_id' => $info['store_id'],
                        'id[!]' => $info['basic_id']
                    ], 'id');
                    $spuList = $basicIds ? mWiki::selectByWhere([
                        'store_id' => $info['store_id'],
                        'is_default' => mWiki::IS_DEFAULT,
                        'basic_id' => $basicIds,
                        'status[!]' => [mWiki::STATUS_DEL, mWiki::STATUS_NORMAL]
                    ], ['id', 'basic_id', 'cover_img', 'title']) : [];
                    $storeInfo['user_info'] = $userInfo;
                    $i = 0;
                    foreach ($spuList as &$row) {
                        $statSign = '';//todo statSign
//                        $statSign = basicStatSign::genStatSign(basicStatSign::MODULE_WIKI_DETAIL_BRAND_CARD, [
//                            basicStatSign::EXTEND_KEY_OBJ_ID => $row['basic_id'],
//                            basicStatSign::EXTEND_KEY_OBJ_TYPE => BlockType::TYPE_WIKI_BASIC,
//                            basicStatSign::EXTEND_KEY_INDEX => $i,
//                        ], ['wiki_id' => $info['basic_id']]);
                        $row['statSign'] = $statSign;
                        $i++;
                    }
                    $storeInfo['spu_list'] = $spuList;
                }
                $data['store_info'] = $storeInfo;
                $data['store_name'] = $storeInfo['store_name'];
            }
            $data['share_info'] = Share::getWikiShare($data);
            $formatData[$wikiId] = $data;
        }
        return $formatData;
    }

    /**
     * 中间页数据格式化
     * @param $infos
     * @param $basicInfos
     * @param int $uid
     * @return array
     */
    private static function _formatMiddleList($infos, $basicInfos, int $uid = 0): array
    {
        $formatData = [];
        foreach ($infos as $wikiId => $info) {
            $title = $info['simple_title'] ? $info['simple_title'] : $info['title'];
            $basicInfo = ($basicInfos && isset($basicInfos[$info['basic_id']])) ? $basicInfos[$info['basic_id']] : [];
            if ($basicInfo) {
                if (($basicInfo['brand_id'] > 0 || $basicInfo['store_id'] > 0) && $basicInfo['basic_state'] == mWikiBasic::STATE_ONLINE && $basicInfo['title']) {
                    $title = $basicInfo['title'];
                }
                //上传主图存在 用wiki_basic的cover_img
                if (isset($basicInfo['cover_img_url']) && !empty($basicInfo['cover_img_url'])) {
                    $info['cover_img'] = $basicInfo['cover_img_url'];
                }
                if (isset($basicInfo['img_urls']) && !empty($basicInfo['img_urls'])) {
                    $info['imgs'] = $basicInfo['img_urls'];
                }
            }
            $price = $info['min_price'] ?: 0;
            $price = $price ?: $info['max_price'];
            $tips = [];
            if (!$title || !$info['cover_img']) {
                $tips = ['text' => '商品信息正在解析中...'];
            }
            if (!$title && $price <= 0 && !$info['cover_img']) {
                $title = clsWiki::getDefaultTitle($info['channel_type']);
            }

            $data = [
                'id' => $info['id'],
                'basic_id' => $info['basic_id'],
                'basic_title' => $basicInfo ? $basicInfo['title'] : '',
                'basic_state' => $basicInfo ? $basicInfo['basic_state'] : -1,
                'type' => 1,
                'title' => $title,
                'ori_min_price' => $info['min_price'],
                "ori_max_price" => $info['max_price'],
                "actual_min_price" => $info['min_price'],
                "actual_max_price" => $info['max_price'],
                "channel" => $info['channel'],
                "channel_spu_status" => $info['channel_spu_status'],
                "actual_stock" => 1,
                "activity_stock" => 0,
                "shop_id" => $info['channel_shop_id'],
                "channel_spu_id" => $info['channel_spu_id'],
                "category_id" => $info['category_id'],
                "second_category_id" => $info['second_category_id'],
                "status" => self::GOODS_STATUS_APP_NORMAL,
                "wiki_status" => $info['status'],
                "cover_img" => $info['cover_img'] ?: self::WIKI_DEFAULT_IMG_3X,
                "brand_id" => $info['brand_id'],
                "store_id" => $info['store_id'],
                "rebate_ratio" => $info['rebate_ratio'],
                'channel_jump_params' => $info['channel_jump_params'],
                'recommendation' => $info['recommendation'] ?? '',
                'recommendation_user' => $info['recommendation_user'] ?? null,
                'want_person_avatars' => $info['want_person_avatars'] ?? null,
                'recommend_list' => $info['recommend_list'] ?? [],
                'fav_count' => $info['fav_count'],
                'buy_count' => $info['buy_count'],
                'is_fav' => $info['is_fav'],
                'is_buy' => $info['is_buy'],
                'imgs' => $info['imgs'],
                'relate_num' => $info['relate_num'],
                'open_other_link' => $info['open_other_link'] ?? '',
                'short_title' => $info['short_title'] ?: null,
                //住友说
                'talk_about_num' => $info['talk_about_num'] ?: 0,
                //品牌说
                'brand_talk_about_num' => $info['brand_talk_about_num'] ?? 0,
                //门店说
                'store_talk_about_num' => $info['store_talk_about_num'] ?? 0,
                //住友说总数
                'talk_about_total' => $info['brand_talk_about_num'] + $info['talk_about_num'],
            ];
            if (isset($info['ranking_info']) && $info['ranking_info']) {
                $data['ranking_info'] = $info['ranking_info'];
            }
            if (isset($info['activity_list']) && $info['activity_list']) {
                $data['activity_list'] = $info['activity_list'];
            }
            $data['brand_info'] = $info['brand_info'] ?? null;
            if (isset($info['store_info']) && $info['store_info']) {
                $data['store_info'] = $info['store_info'];
            }

            if ($tips) {
                $data['tips'] = $tips;
            }
            $formatData[$wikiId] = $data;
        }
        return $formatData;
    }

    /**
     * 今日好物页数据格式化
     * @param $infos
     * @param $basicInfos
     * @param int $uid
     * @return array
     */
    private static function _formatTodayBeforeList($infos, $basicInfos, int $uid = 0): array
    {
        $formatData = [];
        foreach ($infos as $wikiId => $info) {
            //场景图>白底图>商品首图
            if (isset($info['scene_img']) && !empty($info['scene_img'])) {
                $info['cover_img'] = $info['scene_img'];
            } else {
                if (isset($info['white_image']) && !empty($info['white_image'])) {
                    $info['cover_img'] = $info['white_image'];
                }
            }
            $data = [
                'id' => $info['id'],
                'basic_id' => $info['basic_id'],
                'type' => $info['type'],
                "channel" => $info['channel'],
                "shop_id" => $info['channel_shop_id'],
                "cover_img" => $info['cover_img'] ?: self::WIKI_DEFAULT_IMG_3X,
                "channel_spu_id" => $info['channel_spu_id'],
                "brand_id" => $info['brand_id'],
                'channel_jump_params' => $info['channel_jump_params'],
                'want_person' => $info['recommendation'] ?? '',
                'want_person_avatars' => $info['want_person_avatars'] ?? null,
                'is_fav' => $info['is_fav'],
                'is_buy' => $info['is_buy'],
                '3rd_link' => $info['3rd_link'] ?? '',
                'open_other_link' => $info['open_other_link'] ?? ''
            ];
            $data['brand_info'] = $info['brand_info'] ?? null;
            $formatData[$wikiId] = $data;
        }
        return $formatData;
    }

    /**
     * 参数校验
     * @param $wikiIds
     * @param $fieldsGroup
     * @throws \Exception
     */
    private static function _verfyParams($wikiIds, $fieldsGroup)
    {
        try {
            if (!self::checkConstants(self::_CONST_FIELDS_GROUP_PREFIX, $fieldsGroup)) {
                throw new \Exception("请求参数异常");
            } else {
                if (empty($wikiIds)) {
                    throw new \Exception("请求参数异常");
                }
            }
            if (in_array($fieldsGroup, [self::FIELDS_GROUP_DETAIL, self::FIELDS_GROUP_FUNENG_DETAIL], false) && count($wikiIds) > 1) {
                throw new \Exception("详情一次只能查询一条数据");
            }
        } catch (\Exception $e) {
            $trace = [
                'file' => $e->getFile(),
                'line' => $e->getLine(),
                'message' => $e->getMessage(),
            ];
            Log::info('wiki参数校验错误信息', compact('wikiIds', 'fieldsGroup', 'trace'));
            throw new \Exception("请求参数异常");
        }

    }

    private static function getWikiFromGrpc($fieldsGroup, $wikiIds, $uid)
    {
        $uid = ($uid > 0) ? $uid : HhzClient::getUid();
        $params = [
            "wikiIds" => $wikiIds,
            "fieldsGroup" => $fieldsGroup,
            "uid" => $uid,
        ];
        //grpc 调用方式
        $aRet = [];
        $aRes = \Wiki\GrpcClient::getInstance()->getWikiInfo($params);

        if (isset($aRes['result']['list']) && !empty($aRes['result']['list'])) {
            $aRet['list'] = $aRes['result']['list'];
        }
        // http 调用
        // $aRet = \Wiki\HttpClient::getInstance()->getWikiInfo($params);

        $result = [];

        if (isset($aRet['list']) && !empty($aRet['list'])) {

            foreach ($wikiIds as $wikiId) {
                if (isset($aRet['list'][$wikiId]) && !empty($aRet['list'][$wikiId])) {
                    $data = $aRet['list'][$wikiId];
                    $result[$wikiId] = $data;
                }
            }
        }

        Log::info('wiki_grpc结束:', ['params' => $params]);
        return $result;

    }

}
